<template>
  <div v-loading="loading">
    <div v-if="bidProject" class="tl-form-line-title sub-title tl-form" style="height: auto;width: 100%;line-height: 28px;">是否存在评分细则：
      <el-select v-model="projectinfo.existbidscoresecond" filterable @change="changeExistBidScore" :disabled="existbidscoredisabled || projectinfo.projectmanagercode !== user.code">
        <el-option v-for="item in codeModel.enabledList" :key="item.code" :label="item.name" :value="item.code" />
      </el-select>
      <el-button v-if="projectinfo.existbidscoresecond === '0' && !existbidscoredisabled && projectinfo.projectmanagercode === user.code" type="primary" @click="doUnBidScoreApproval" :loading="saveLoading"><svg-icon icon-class="send" />提交审批</el-button>
      <el-button v-if="projectinfo.existbidscoresecond === '0'" @click="$refs.history1.visible = true"  type="primary">
        <svg-icon icon-class="list" />审批历史
      </el-button>
      <tl-approval-history ref="history1" sourceType="MpmProjectUnBidScore" :sourceId="existbidscoreid" />
    </div>
    <div v-if="projectinfo.existbidscoresecond === '1'">
    <el-collapse v-model="activeNames">
      <el-collapse-item title="专家拜访" name="expert" class="colitem">
        <tl-edit-list ref="editListForm" :bidscoretimes="'2'" :projectinfo="projectinfo" style="margin-left: 10px"></tl-edit-list>
      </el-collapse-item>
    </el-collapse>
      <div v-show="false">
        <tl-line  @isloading="isloading" :projectinfo="projectinfo" ></tl-line>
      </div>
      <div v-if="secondshow" style="position: relative">
        <div class="subtitle-button" style="float: right">
          <!-- <el-button type="primary" v-if="true" class="filter-item" icon="el-icon-download" @click="downloadTemplate(templateName, fileName)">下载模板</el-button> -->
          <tl-Import-Excel  v-show="false" ref="importRef" :businessFullScore="businessFullScore" :technologyFullScore="technologyFullScore" :uploadUrl="url.importExcel" tableName="MpmProjectBidScore" :times="'2'" :projectinfo="projectinfo" @refresh="doRefresh"></tl-Import-Excel>
          <!-- <el-button type="primary" v-if="true" class="filter-item" icon="el-icon-download" @click="doRealExportExcel">导出</el-button> -->
          <el-button type="primary"  @click="doSave" :loading="saveLoading"><svg-icon icon-class="send" />保存</el-button>&nbsp;&nbsp;
          <el-dropdown  trigger="click">
              <el-button type="primary"  @click="handleClick">
                导入导出<i class="el-icon-arrow-down el-icon--right"></i>
              </el-button>
              <el-dropdown-menu slot="dropdown" >
                <el-dropdown-item v-if="secondedit && this.importCheckExcel && this.importCheckExcel1 && this.importCheckExcel2" @click.native="openViewDialog">导入</el-dropdown-item>
                <el-dropdown-item v-if="secondedit && this.importCheckExcel && this.importCheckExcel1 && this.importCheckExcel2" @click.native="downloadTemplate(templateName, fileName)">下载模板</el-dropdown-item>
                <el-dropdown-item @click.native="doRealExportExcel">导出</el-dropdown-item>
              </el-dropdown-menu>
          </el-dropdown>&nbsp;&nbsp;
          <tl-attachment ref="secondAttachmentRef" sourceType="MpmProjectBidScoreSecond" :sourceId="projectinfo.id" :disabled="false" :editable="attachmentEdit"></tl-attachment>
          <el-button type="primary" @click="doSubmitApproval2" :loading="submitLoading" v-if="secondedit && issecondpublish"><svg-icon icon-class="send" />发布</el-button>
          <el-button type="primary" @click="getScoreIdHis2"><svg-icon icon-class="list" />审批历史</el-button>
        </div>
        <div class="tl-form-line-title">二阶段自评（挂网阶段自评）</div>
        <div style="display: flex; position: absolute; top: -5px; left: 280px;font-size: 18px;font-weight: bold;line-height: 28px;">要求：高于<el-input size="mini" style="color: black;width: 70px;margin: 0 10px" :disabled="!secondedit" @change="changescore" v-model="fullScoreInfo.requirescore" oninput="this.value=this.value.match(/\d{0,}\.?\d{0,2}/)" ></el-input>分</div>
        <tl-line :ref="'line3'" :times="'2'" @getTotalScore="getTotalScore" @isloading="isloading" @doSave="doSave" :isapproval="false" :biddate="biddatefortime2" :editdisabled="secondedit" :type="'1'" :projectinfo="projectinfo" :title="'商务'" :editFeedback="editFeedback" @showFullScreen="showFullScreen('line3')" @getFullScoreInfo="getFullScoreInfo" @getdata="getdata" @getButtonStatus="AddStatus" @getIfCheck="getIfCheck" @HasData="whether" @HasTotalfullscore= "HasTotalfullscore" ></tl-line>
        <tl-line :ref="'line4'" :times="'2'" @getTotalScore="getTotalScore" @isloading="isloading" @doSave="doSave" :isapproval="false" :biddate="biddatefortime2" :editdisabled="secondedit" :type="'2'" :projectinfo="projectinfo" :title="'技术'" :editFeedback="editFeedback" @showFullScreen="showFullScreen('line4')" @getdata="getdata1" @getButtonStatus="AddStatus1" @getIfCheck="getIfCheck1" @HasData="whether1" @HasTotalfullscore= "HasTotalfullscore1"></tl-line>
        <tl-offer :ref="'line5'" :times="'2'" :editable="secondedit" :type="'3'" :projectinfo="projectinfo" :title="'报价'"></tl-offer>
      </div>
      <tl-edit ref="editForm" :projectinfo="projectinfo"></tl-edit>
      <tl-approval-history ref="history" sourceType="MpmProjectBidScore" :sourceId="scoreid" />
      <tl-line ref="fullScreenRef" :render="'el-dialog'" v-bind="fullScreenProps"  @refresh="refreshScoreList"></tl-line>
    </div>
  </div>
</template>

<script>
  /** mixins */
  import { mixin_approval_edit } from '@tapui/mixins/mixin_approval_edit'
  import { mixin_bid_score } from './mixin/mixin_bid_score'
  import { mixin_download_template } from '@/mixins/mixin_download_template'
  /** 子组件 */
  import TlRefStakeholder from '../mpmProjectStakeholder/refList'
  import TlLine from './indexFrame'
  import tlEdit from './edit'
  import tlOffer from './indexFrameOffer'
  import tlEditList from '@/views/mpm/mpmProjectVisitExpert/editList'
  import tlImportExcel from './components/importExcel'
  /** 工具类 */
  import { putAction, getAction, postAction, deleteAction } from '@tapui/utils/http'
  import { exportExcel, exportExcelAxio } from '@tapui/api/office'
  /** VUE配置 */
  export default {
    mixins: [mixin_approval_edit, mixin_bid_score, mixin_download_template],
    components: { TlRefStakeholder, TlLine, tlEdit, tlEditList, tlOffer, tlImportExcel },
    data() {
      return {
        moduleTitle: '评标细则信息表',
        urlPrefix: '/mpm/projectBidScore/',
        url: {
          // 额外的url
          queryScoreInfo: '/mpm/projectBidScore/queryScoreInfo/',
          queryCodeList: '/mpm/projectBidScore/dataCodeList',
          queryMpmInfo: '/mpm/projectBidScore/queryMpmInfo/',
          fullScoreDoSave: '/mpm/projectBidFullScore/doSave/',
          updateProjectInfo: '/mpm/projectBidScore/updateProjectInfo/',
          submitUnBidScore: '/mpm/projectUnBidScore/submitUnBidScore/',
          getScoreIdHis: '/mpm/projectBidScore/getScoreIdHis',
          downloadTemplate: '/mpm/projectBidScore/downloadTemplate',
          importExcel: '/mpm/projectBidScore/importExcel',
          exportExcel: process.env.BASE_API + '/mpm/projectBidScore/exportExcelForScore'
        },
        externalQueryParam: {
          qry_projectcode: this.projectinfo.projectcode // 项目编号
        },
        isdisbledtime: true,
        firstedit: true,
        secondedit: false,
        secondshow: true,
        loading: true,
        listindex: 0,
        biddatefortime1: new Date(),
        biddatefortime2: new Date(),
        scoreid: 0,
        firsthis: false,
        secondhis: false,
        targetscoretotal: '0',
        selfscoretotal: '0',
        isfirstpublish: true,
        issecondpublish: true,
        editFeedback: true,
        purchasepattern: '0',
        existbidscoredisabled: false,
        fullScreenProps: {},
        fullScreenRefName: '',
        activeNames: ['expert'],
        templateName: 'assessTemplate.xlsx',
        fileName: '阶段自评导入模板.xlsx',
        exportdata: {},
        exportdata1: {},
        addbusiness: null,
        addtech: null,
        ifBusCheck: null,
        ifTechCheck: null,
        hasBusdata: null,
        hasTechdata: null,
        busHasTotalfullscore: null,
        techHasTotalfullscore: null,
        businessFullScore: '100',
        technologyFullScore: '100',
        existbidscoreid: 0
      }
    },
    props: {
      projectinfo: {}
    },
    computed: {
      attachmentEdit() {
        if (this.projectinfo.projectmanagercode === this.user.code) {
          return true
          // if (this.$refs.firstAttachmentRef && this.$refs.firstAttachmentRef.fileCount >= 1 && this.$refs.firstAttachmentRef.fileList.length >= 1) {
          //   return true
          // } else {
          //   return false
          // }
        } else {
          return false
        }
      },
     // 导出状态
      importCheckExcel() {
        // 判断当前用户是否为项目经理，如果是，则允许导入
        if (this.$store.getters.user.code === this.projectinfo.projectmanagercode) {
            return true
        } else {
            return false
        }
      },
        // 导出状态1
      importCheckExcel1() {
        // 有一新增按钮不显示 或者有一审核数据都不显示
        if (this.ifBusCheck === true || this.ifTechCheck === true) {
           return false
        } else {
           return true
        }
      },
       // 导出状态2
      importCheckExcel2() {
        // 判断满分合计是否有数据,都有数据才能显示
        if (this.busHasTotalfullscore === true && this.techHasTotalfullscore === true) {
           return true
        } else {
           return false
        }
      },
      bidProject() {
        return this.purchasepattern === '11' || this.purchasepattern === '12' || this.purchasepattern === '13'
      }
    },
    methods: {
      getTotalScore(val, type) {
        if (type === '1') {
          this.businessFullScore = val
        } else {
          this.technologyFullScore = val
        }
      },
      // 导入导出触发
      handleClick() {
        this.$refs.line3.getIfCheck()
        this.$refs.line4.getIfCheck()
        this.$refs.line3.getIfHasTotalfullscore()
        this.$refs.line4.getIfHasTotalfullscore()
        console.log(this.addbusiness)
        console.log(this.addtech)
        console.log(this.ifBusCheck)
        console.log(this.ifTechCheck)
      },
      showFullScreen(refName) {
        this.fullScreenProps = this.$refs[refName].$options.propsData
        this.fullScreenRefName = refName
        this.$refs.fullScreenRef.dialogVisible = true
        this.$nextTick(() => {
          this.$refs.fullScreenRef.loadData({})
        })
      },
      refreshScoreList() {
        this.$refs[this.fullScreenRefName].loadData({})
      },
      doUnBidScoreApproval() {
        this.submitLoading = true
        this.$tap.confirm('确定提交无评分细则申请吗？提交后不可修改！').then((_) => {
          if (!this.beforeApproval()) {
            this.submitLoading = false
            return
          }
          putAction(this.url.submitUnBidScore, { projectcode: this.projectinfo.projectcode, projectname: this.projectinfo.projectname, times: '2' }).then((res) => {
            if (res.success) {
              this.existbidscoredisabled = true
              this.existbidscoreid = res.result.existbidscoreid
              this.$tap.message(res.message, 'success')
            } else {
              this.$tap.alert(res.message, 'warning')
            }
            this.submitLoading = false
          })
        })
          .catch((_) => {
            this.submitLoading = false
          })
      },
      changeExistBidScore() {
        getAction(this.url.updateProjectInfo, { projectcode: this.projectinfo.projectcode, existbidscore: this.projectinfo.existbidscoresecond, projectname: this.projectinfo.projectname, times: '2' }).then((res) => {})
      },
      async doSave() {
        await this.fullScoreUpdate(this.fullScoreInfo)
        this.saveValue = this.fullScoreInfo.requirescore
        if (this.$refs.line5) {
          await this.$refs.line5.doSave()
        }
        let fullScorelist = {
          scoreMap1: {
            times: '1',
            type: '1',
            projectcode: this.projectinfo.projectcode,
            totalfullsocre: this.$refs.line1 ? this.$refs.line1.totalfullscore : ''
          },
          scoreMap2: {
            times: '1',
            type: '2',
            projectcode: this.projectinfo.projectcode,
            totalfullsocre: this.$refs.line2 ? this.$refs.line2.totalfullscore : ''
          },
          scoreMap3: {
            times: '2',
            type: '1',
            projectcode: this.projectinfo.projectcode,
            totalfullsocre: this.$refs.line3 ? this.$refs.line3.totalfullscore : '100'
          },
          scoreMap4: {
            times: '2',
            type: '2',
            projectcode: this.projectinfo.projectcode,
            totalfullsocre: this.$refs.line4 ? this.$refs.line4.totalfullscore : '100'
          }
        }
        this.saveLoading = true
        // 增加唯一单号
        postAction(this.url.fullScoreDoSave, fullScorelist)
          .then((res) => {
            if (res.success) {
            } else {
              this.$tap.alert(res.message, 'warning')
            }
            this.saveLoading = false
          })
          .catch((err) => {
            this.saveLoading = false
          })
      },
      /** 一阶段自评发布 */
      doSubmitApproval1() {
        if (!this.url.submit) {
          this.$tap.alert('请设置审批地址!', 'warning')
          return
        }
        if (!this.beforeApproval()) {
          return
        }
        if (this.$refs.firstAttachmentRef.fileCount === 0 && this.$refs.firstAttachmentRef.fileList.length === 0) {
          this.$tap.alert('请上传一阶段自评附件！', 'warning')
          return
        }
        let tipInfo = '确定发布吗？'
        let tipInfoKey = false
        let firstnopublishinfo = ''
        // 一阶段自评发布
        let first = true
        if (this.$refs.line2.fullscoretotal > parseFloat(this.$refs.line2.totalfullscore)) {
          firstnopublishinfo = '技术满分大于满分合计，'
          // this.$tap.alert('一阶段自评-技术满分大于满分合计，不允许发布！')
          first = false
        }
        if (this.$refs.line1.fullscoretotal > parseFloat(this.$refs.line1.totalfullscore)) {
          firstnopublishinfo = '商务满分大于满分合计，' + firstnopublishinfo
          // this.$tap.alert('一阶段自评-商务满分大于满分合计，不允许发布！')
          first = false
        }
        if (!first) {
          this.$tap.alert('一阶段自评-' + firstnopublishinfo + '不允许发布！')
          this.submitLoading = false
          return
        }
        if (this.$refs.line2.fullscoretotal < parseFloat(this.$refs.line2.totalfullscore)) {
          tipInfo = '技术满分之和小于技术总分，'
          tipInfoKey = true
        }
        if (this.$refs.line1.fullscoretotal < parseFloat(this.$refs.line1.totalfullscore)) {
          // 当前已填商务满分之和小于商务总分，还可继续新增商务自评，确认发布吗？
          if (tipInfoKey) {
            tipInfo = '商务满分之和小于商务总分，' + tipInfo
          } else {
            tipInfo = '商务满分之和小于商务总分，'
          }
          tipInfoKey = true
        }
        let key = true
        if (this.$refs.line1.datas.length > 0) {
          for (let i = 0; i < this.$refs.line1.datas.length; i++) {
            if (this.$refs.line1.datas[i].state === 0 || this.$refs.line1.datas[i].state === 2) {
              this.$set(this, 'model', this.$refs.line1.datas[i])
              key = false
              break
            }
          }
        }
        if (this.$refs.line2.datas.length > 0) {
          for (let i = 0; i < this.$refs.line2.datas.length; i++) {
            if (this.$refs.line2.datas[i].state === 0 || this.$refs.line2.datas[i].state === 2) {
              this.$set(this, 'model', this.$refs.line2.datas[i])
              key = false
              break
            }
          }
        }
        if (key) {
          this.$tap.alert('当前无可发布内容，请确认！')
          this.submitLoading = false
          return
        }
        if (tipInfoKey) {
          tipInfo = '当前已填' + tipInfo + '还可继续新增自评，确认发布吗？'
        }
        this.submitLoading = true
        this.$tap
          .confirm(tipInfo)
          .then(_ => {
            this.doSave()
            putAction(this.url.submit, this.model).then(res => {
              if (res.success) {
                this.$tap.message(res.message, 'success')
                this.queryScoreInfo()
                this.$refs.line1.loadData({})
                this.$refs.line2.loadData({})
                this.afterApproval()
              } else {
                this.$tap.alert(res.message, 'warning')
              }
              this.submitLoading = false
            })
          })
          .catch(_ => {
            this.submitLoading = false
          })
      },
      /** 提交审批 */
      doSubmitApproval2() {
        if (!this.url.submit) {
          this.$tap.alert('请设置审批地址!', 'warning')
          return
        }
        if (!this.beforeApproval()) {
          return
        }
        if (this.$refs.secondAttachmentRef.fileCount === 0 && this.$refs.secondAttachmentRef.fileList.length === 0) {
          this.$tap.alert('请上传二阶段自评附件！', 'warning')
          return
        }
        let tipInfo = '确定发布吗？'
        let tipInfoKey = false
        let secondnopublishinfo = ''
        // 二阶段自评发布
        if (this.secondshow) {
          let second = true
          if (this.$refs.line3.fullscoretotal > parseFloat(this.$refs.line3.totalfullscore)) {
            secondnopublishinfo = '技术满分大于满分合计，'
            // this.$tap.alert('二阶段自评-商务满分大于满分合计，不允许发布！')
            second = false
          }
          if (this.$refs.line4.fullscoretotal > parseFloat(this.$refs.line4.totalfullscore)) {
            secondnopublishinfo = '商务满分大于满分合计，' + secondnopublishinfo
            // this.$tap.alert('二阶段自评-技术满分大于满分合计，不允许发布！')
            second = false
          }
          if (!second) {
            this.$tap.alert('二阶段自评-' + secondnopublishinfo + '不允许发布！')
            this.submitLoading = false
            return
          }
          if (this.$refs.line3.fullscoretotal < parseFloat(this.$refs.line3.totalfullscore)) {
            tipInfo = '技术满分之和小于技术总分，'
            tipInfoKey = true
          }
          if (this.$refs.line4.fullscoretotal < parseFloat(this.$refs.line4.totalfullscore)) {
            if (tipInfoKey) {
              tipInfo = '商务满分之和小于商务总分，' + tipInfo
            } else {
              tipInfo = '商务满分之和小于商务总分，'
            }
            tipInfoKey = true
          }
          for (let i = 0; i < this.$refs.line3.datas.length; i++) {
            if (!this.$refs.line3.datas[i].planenddate && this.$refs.line3.datas[i].fullscore !== this.$refs.line3.datas[i].selfscore) {
              this.$tap.alert('请填写计划完成日期')
              this.submitLoading = false
              return
            }
          }
          for (let i = 0; i < this.$refs.line4.datas.length; i++) {
            if (!this.$refs.line4.datas[i].planenddate && this.$refs.line4.datas[i].fullscore !== this.$refs.line4.datas[i].selfscore) {
              this.$tap.alert('请填写计划完成日期')
              this.submitLoading = false
              return
            }
          }
        }
        let key = true
        if (this.$refs.line3.datas.length > 0) {
          for (let i = 0; i < this.$refs.line3.datas.length; i++) {
            if (this.$refs.line3.datas[i].state === 0 || this.$refs.line3.datas[i].state === 2) {
              this.$set(this, 'model', this.$refs.line3.datas[i])
              key = false
              break
            }
          }
        }
        if (this.$refs.line4.datas.length > 0) {
          for (let i = 0; i < this.$refs.line4.datas.length; i++) {
            if (this.$refs.line4.datas[i].state === 0 || this.$refs.line4.datas[i].state === 2) {
              this.$set(this, 'model', this.$refs.line4.datas[i])
              key = false
              break
            }
          }
        }
        if (key) {
          this.$tap.alert('当前无可发布内容，请确认！')
          this.submitLoading = false
          return
        }
        if (tipInfoKey) {
          tipInfo = '当前已填' + tipInfo + '还可继续新增自评，确认发布吗？'
        }
        this.submitLoading = true
        this.$tap
          .confirm(tipInfo)
          .then(async _ => {
            if (this.$refs.line5) {
              await this.$refs.line5.doSave()
            }
            this.doSave()
            putAction(this.url.submit, this.model).then(res => {
              if (res.success) {
                this.$tap.message(res.message, 'success')
                this.queryScoreInfo()
                this.$refs.line3.loadData({})
                this.$refs.line4.loadData({})
                this.afterApproval()
              } else {
                this.$tap.alert(res.message, 'warning')
              }
              this.submitLoading = false
            })
          })
          .catch(_ => {
            this.submitLoading = false
          })
      },
      /** 提交审批 */
      doSubmitApproval() {
        if (!this.url.submit) {
          this.$tap.alert('请设置审批地址!', 'warning')
          return
        }
        if (!this.beforeApproval()) {
          return
        }
        let tipInfo = '确定发布吗？'
        // 一阶段自评发布
        if (this.firstedit && this.isfirstpublish) {
          let first = true
          if (this.$refs.line2.fullscoretotal > parseFloat(this.$refs.line2.totalfullscore)) {
            this.$tap.alert('一阶段自评-技术满分之和大于满分合计，不允许发布！')
            first = false
          }
          if (this.$refs.line1.fullscoretotal > parseFloat(this.$refs.line1.totalfullscore)) {
            this.$tap.alert('一阶段自评-商务满分之和大于满分合计，不允许发布！')
            first = false
          }
          if (!first) {
            this.submitLoading = false
            return
          }
          if (this.$refs.line2.fullscoretotal < parseFloat(this.$refs.line2.totalfullscore)) {
            tipInfo = '当前已填技术满分之和小于技术总分，还可继续新增技术自评，确认发布吗？'
          }
          if (this.$refs.line1.fullscoretotal < parseFloat(this.$refs.line1.totalfullscore)) {
            tipInfo = '当前已填商务满分之和小于商务总分，还可继续新增商务自评，确认发布吗？'
          }
        }
        // 二阶段自评发布
        if (this.secondshow) {
          let second = true
          if (this.$refs.line3.fullscoretotal > parseFloat(this.$refs.line3.totalfullscore)) {
            this.$tap.alert('二阶段自评-商务满分大于满分合计，不允许发布！')
            second = false
          }
          if (this.$refs.line4.fullscoretotal > parseFloat(this.$refs.line4.totalfullscore)) {
            this.$tap.alert('二阶段自评-技术满分大于满分合计，不允许发布！')
            second = false
          }
          if (!second) {
            this.submitLoading = false
            return
          }
          if (this.$refs.line3.fullscoretotal < parseFloat(this.$refs.line3.totalfullscore)) {
            tipInfo = '当前已填商务满分之和小于商务总分，还可继续新增商务自评，确认发布吗？'
          }
          if (this.$refs.line4.fullscoretotal < parseFloat(this.$refs.line4.totalfullscore)) {
            tipInfo = '当前已填技术满分之和小于技术总分，还可继续新增技术自评，确认发布吗？'
          }
          for (let i = 0; i < this.$refs.line3.datas.length; i++) {
            if (!this.$refs.line3.datas[i].planenddate && this.$refs.line3.datas[i].fullscore !== this.$refs.line3.datas[i].selfscore) {
              this.$tap.alert('请填写计划完成日期')
              this.submitLoading = false
              return
            }
          }
          for (let i = 0; i < this.$refs.line4.datas.length; i++) {
            if (!this.$refs.line4.datas[i].planenddate && this.$refs.line4.datas[i].fullscore !== this.$refs.line4.datas[i].selfscore) {
              this.$tap.alert('请填写计划完成日期')
              this.submitLoading = false
              return
            }
          }
        }
        this.submitLoading = true
        this.$tap
          .confirm(tipInfo)
          .then(_ => {
            if (this.firstedit) {
              let key = true
              if (this.$refs.line1.datas.length > 0) {
                for (let i = 0; i < this.$refs.line1.datas.length; i++) {
                  if (this.$refs.line1.datas[i].state === 0 || this.$refs.line1.datas[i].state === 2) {
                    this.$set(this, 'model', this.$refs.line1.datas[i])
                    key = false
                    break
                  }
                }
              }
              if (this.$refs.line2.datas.length > 0) {
                for (let i = 0; i < this.$refs.line2.datas.length; i++) {
                  if (this.$refs.line2.datas[i].state === 0 || this.$refs.line2.datas[i].state === 2) {
                    this.$set(this, 'model', this.$refs.line2.datas[i])
                    key = false
                    break
                  }
                }
              }
              if (key) {
                this.$tap.alert('当前无可发布内容，请确认！')
                this.submitLoading = false
                return
              }
            } else {
              let key = true
              if (this.$refs.line3.datas.length > 0) {
                for (let i = 0; i < this.$refs.line3.datas.length; i++) {
                  if (this.$refs.line3.datas[i].state === 0 || this.$refs.line3.datas[i].state === 2) {
                    this.$set(this, 'model', this.$refs.line3.datas[i])
                    key = false
                    break
                  }
                }
              }
              if (this.$refs.line4.datas.length > 0) {
                for (let i = 0; i < this.$refs.line4.datas.length; i++) {
                  if (this.$refs.line4.datas[i].state === 0 || this.$refs.line4.datas[i].state === 2) {
                    this.$set(this, 'model', this.$refs.line4.datas[i])
                    key = false
                    break
                  }
                }
              }
              if (key) {
                this.$tap.alert('当前无可发布内容，请确认！')
                this.submitLoading = false
                return
              }
            }
            this.doSave()
            putAction(this.url.submit, this.model).then(res => {
              if (res.success) {
                this.$tap.message(res.message, 'success')
                // if (this.firstedit) {
                //   this.firstedit = false
                //   this.firsthis = true
                //   this.scoreid = this.model.id
                // } else {
                //   this.secondedit = false
                //   this.secondhis = true
                //   this.scoreid = this.model.id
                // }
                this.afterApproval()
              } else {
                this.$tap.alert(res.message, 'warning')
              }
              this.submitLoading = false
            })
          })
          .catch(_ => {
            this.submitLoading = false
          })
      },
      queryMpmInfo() {
        return getAction(this.url.queryMpmInfo, { projectid: this.projectinfo.id, times: '2' }).then((res) => {
          if (res.success) {
            this.$set(this.projectinfo, 'existbidscoresecond', res.result.existbidscoresecond)
            this.purchasepattern = res.result.purchasepattern
            this.existbidscoredisabled = res.result.existbidscoredisabled
            this.existbidscoreid = res.result.existbidscoreid
            this.$nextTick(() => {
              if (this.projectinfo.existbidscoresecond && this.projectinfo.existbidscoresecond === '1') {
                this.queryScoreInfo()
                this.listindex = 0
              } else {
                this.loading = false
              }
            })
            if (res.result.bidbegindate === null) {
              this.biddatefortime1 = new Date(this.projectinfo.planenddate)
            } else {
              this.biddatefortime1 = new Date(res.result.bidbegindate)
            }
            if (res.result.bidenddate === null) {
              this.biddatefortime2 = new Date(this.projectinfo.planenddate)
            } else {
              this.biddatefortime2 = new Date(res.result.bidenddate)
            }
          } else {
            this.$tap.alert(res.message, 'warning')
          }
        })
      },
      queryScoreInfo() {
        return getAction(this.url.queryScoreInfo, { projectcode: this.projectinfo.projectcode }).then((res) => {
          if (res.success) {
            this.scoreid = res.result.scoreid
            if (this.user.code !== this.projectinfo.projectmanagercode) {
              this.firstedit = false
              this.secondedit = false
              this.secondshow = res.result.secondshow
            } else {
              this.firstedit = res.result.firstedit
              this.secondedit = res.result.secondedit
              this.secondshow = res.result.secondshow
            }
            this.isloading()
            this.scoreid = res.result.scoreid
            this.firsthis = res.result.firsthis
            this.secondhis = res.result.secondhis
            this.editFeedback = res.result.editFeedback
          } else {
            this.$tap.alert(res.message, 'warning')
          }
        })
      },
      isloading() {
        this.listindex++
        let index = 2
        if (this.secondshow) {
          index = 2
        }
        if (this.listindex >= index) {
          this.loading = false
        }
        // if (this.$refs.line1 && this.$refs.line2) {
        //   this.isfirstpublish = this.$refs.line1.iscanpublish && this.$refs.line2.iscanpublish
        // }
        if (this.$refs.line3 && this.$refs.line4) {
          this.issecondpublish = this.$refs.line3.iscanpublish && this.$refs.line4.iscanpublish
        }
      },
      getScoreIdHis1() {
        this.getScoreIdHis('1')
      },
      getScoreIdHis2() {
        this.getScoreIdHis('2')
      },
      getScoreIdHis(times) {
        let param = {
          qry_projectcode: this.projectinfo.projectcode,
          qry_times: times
        }
        getAction(this.url.getScoreIdHis, param).then(res => {
          if (res.success) {
            this.scoreid = res.result.scoreid
            this.$refs.history.visible = true
          } else {
            this.$tap.alert('获取审批历史失败，请联系管理员！', 'warning')
          }
        })
      },
      // 获取回调数据
      getdata(data) {
         this.exportdata = data
      },
      // 获取回调数据
      getdata1(data1) {
         this.exportdata1 = data1
      },
      // 获取新增商务回调状态
      AddStatus(data) {
         this.addbusiness = data
      },
      // 获取新增技术回调状态
      AddStatus1(data1) {
         this.addtech = data1
      },
      // 检查商务是否有审核数据
      getIfCheck(data) {
        this.ifBusCheck = data
      },
      // 检查技术是否有审核数据
      getIfCheck1(data1) {
        this.ifTechCheck = data1
      },
      // 执行导出操作
      doRealExportExcel() {
         this.$refs.line3.exportExportExcel()
         this.$refs.line4.exportExportExcel()
         this.doAllExportExcel(this.exportdata, this.exportdata1)
      },
      // 融合数据导出方法
      doAllExportExcel(exportdata, exportdata1) {
         exportdata.qry_type = exportdata.qry_type + ',' + exportdata1.qry_type
         exportExcelAxio({ url: this.url.exportExcel, data: exportdata })
        .then((res) => {
          var reader = new FileReader()
          reader.readAsText(res.data, 'utf-8')
          reader.onload = () => {
            try {
              var info = JSON.parse(reader.result)
              this.$tap.alert(info.message)
            } catch (e) {
              var isTaskExport = res.headers.istaskexport
              if (isTaskExport === '1') {
                this.$tap.alert('系统正在导出，请到excel导出任务页面下载')
              } else {
                var blob = new Blob([res.data], { type: 'application/octet-stream;charset=utf-8' })
                // var filename = decodeURI(res.headers['filename'])
                // if (typeof filename === 'undefined') {
                var filename = '导出数据.xlsx'
                // }
                var tempObjectUrl = window.URL.createObjectURL(blob)
                var aLink = document.createElement('a')
                aLink.style.display = 'none'
                aLink.download = filename
                aLink.href = tempObjectUrl
                document.body.appendChild(aLink)
                aLink.click()
                document.body.removeChild(aLink)
                window.URL.revokeObjectURL(tempObjectUrl)
              }
            }
          }
        })
        .catch((error) => {
          this.$tap.alert(error, 'warning')
        })
      },
      doRefresh() {
         this.$refs.line3.doRefresh()
         this.$refs.line4.doRefresh()
      },
      // 导入函数
      openViewDialog() {
         this.$refs.line3.getIfHasData()
         this.$refs.line4.getIfHasData()
         // 含有数据时判断是否导入，没有数据直接导入
         if (this.hasBusdata === true || this.hasTechdata === true) {
          this.$tap.confirm('确定导入数据吗，导入将覆盖已存在的数据？').then((_) => {
          this.$refs.importRef.$refs.importRef1.$el.click()
          })
         } else {
           this.$refs.importRef.$refs.importRef1.$el.click()
         }
      },
      // 回调状态
      whether(data) {
        this.hasBusdata = data
      },
      whether1(data) {
        this.hasTechdata = data
      },
       // 控制满分合计
      HasTotalfullscore(data) {
        this.busHasTotalfullscore = data
      },
       // 控制满分合计
      HasTotalfullscore1(data) {
        this.techHasTotalfullscore = data
      }
    },
    created() {
      this.queryMpmInfo()
    }
  }
</script>
<style scoped lang="scss">
  $small:600px;
  $medium:1380px;
  $large:1600px;

  .stakeholderForm {
    margin-top: 15px;
    margin-left: -220px;
    .el-row {
      margin-bottom: 2px;
    }
    /* 隐藏禁用状态下的提示 */
    .is-disabled ::placeholder {
      color: transparent !important;
    }
  }
  .tl-ref-user {
    /deep/ .tl-ref-selector {
      .el-button {
        background-color: red !important;
      }
    }
  }
  //将按钮移出文档流，避免占用空间导致标题挤压换行
  .subtitle-button{
    position:absolute;
    right:5px
  }
  /deep/ .colitem.el-collapse-item .el-collapse-item__header {
    font-size: 18px !important;
    font-weight: bold;
    height: 20px;
    line-height: 20px;
    border-left: 4px solid #409eff !important;
    padding-left: 8px;
    margin: 17px 0 12px 15px;
    overflow: hidden;
  }
</style>
